import request from '@/utils/request'
import {saveAs} from 'file-saver'

// 查询组件部署管理列表
export function listComponentDeploy(query) {
    return request({
        url: '/admin-api/deploy/component-deploy/page',
        method: 'get',
        params: query
    })
}

// 查询组件部署管理详细
export function getComponentDeploy(query) {
    return request({
        url: '/admin-api/deploy/component-deploy/get',
        method: 'get',
        params: query
    })
}

// 新增组件部署管理
export function addComponentDeploy(data) {
    return request({
        url: '/admin-api/deploy/component-deploy/create',
        method: 'post',
        data: data
    })
}

// 修改组件部署管理
export function updateComponentDeploy(data) {
    return request({
        url: '/admin-api/deploy/component-deploy/update',
        method: 'put',
        data: data
    })
}

// 删除组件部署管理
export function delComponentDeploy(data) {
    return request({
        url: '/admin-api/deploy/component-deploy/delete',
        method: 'delete',
        params: data
    })
}

// 下载文件
export function exportComponentDeploy(data) {
    return request({
        url: '/admin-api/deploy/component-deploy/export-excel',
        method: 'get',
        params: data,
        responseType: 'blob',
    }).then(res => {
        const blob = new Blob([res], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"})
        saveAs(blob, decodeURIComponent('组件部署记录.xlsx'))
    })
}